home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / printing / std file saver / source / stringutils.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  1.3 KB  |  48 lines

  1. /*
  2. ** Copyright 1991-1996 Apple Computer. All rights reserved.
  3. **
  4. **    You may incorporate this sample code into your applications without
  5. **    restriction, though the sample code has been provided "AS IS" and the
  6. **    responsibility for its operation is 100% yours.  However, what you are
  7. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  8. **    after having made changes. If you're going to re-distribute the source,
  9. **    we require that you make it clear in the source that the code was
  10. **    descended from Apple Sample Code, but that you've made changes.
  11. */
  12.  
  13. #include <Types.h>
  14. #include <Memory.h>
  15. #include <TextUtils.h>
  16.  
  17. #define PStrlen(s) (*s)
  18.  
  19. void PStrcpy(unsigned char *dest, unsigned char *src)
  20. {
  21.     BlockMoveData(src, dest, PStrlen(src) + 1);
  22. }
  23.  
  24. void PStr_InsertChar(unsigned char *s, unsigned char c)
  25. {
  26.     unsigned char theLength = PStrlen(s);
  27.  
  28.     if (theLength >= 255) return;
  29.     BlockMoveData(s+1,s+2,theLength);
  30.     *(s+1) = c;
  31.     PStrlen(s) = theLength + 1;
  32. }
  33.  
  34. unsigned char *PStrcat(unsigned char *dst, unsigned char *src)
  35. {
  36.     unsigned char srcLength = PStrlen(src);
  37.     unsigned char dstLength = PStrlen(dst);
  38.  
  39.     if ((srcLength + dstLength) > 255) {
  40.         return dst;
  41.     }
  42.     BlockMoveData(src+1,dst+dstLength+1,srcLength);
  43.     *dst = (unsigned char)(srcLength + dstLength);
  44.  
  45.     return dst;
  46. }
  47.  
  48.